package com.cyz.user.userService.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cyz.common.bean.CardButton;
import com.cyz.user.userService.ButtonService;
import com.cyz.user.userService.CardButtonService;
import com.cyz.common.mapper.CardButtonMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author 34928
* @description 针对表【card_button】的数据库操作Service实现
* @createDate 2023-02-28 21:57:14
*/
@Service
public class CardButtonServiceImpl extends ServiceImpl<CardButtonMapper, CardButton>
    implements CardButtonService {

    @Autowired
    private ButtonService buttonService;

    @Override
    public List<String> getbuttonNamesByCardId(Integer id) {
        LambdaQueryWrapper<CardButton> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(CardButton::getCardId,id);
        List<CardButton> list = list(lambdaQueryWrapper);
        List<String> buttonNames = new ArrayList<>();
        list.stream()
                .map(CardButton::getButtonId)
                .forEach(item ->{
                    buttonNames.add(buttonService.getById(item).getName());
                });
        return buttonNames;
    }
}




